const app = getApp();

Component({
  properties: {
    params: {
      type: Object,
      value: {}
    }
  },
  data: {},
  ready() {
    const {
      height,
      content,
      color,
      background,
      background_image,
      font_size,
      font_weight,
      text_align,
      link,
      link_tips
    } = this.properties.params

    this.setData({
      height: height,
      content: content,
      color: color,
      background:background,
      background_image: background_image,
      font_size: this.getFontSize(font_size),
      font_weight: font_weight,
      text_align: text_align,
      link: link,
      link_tips: link_tips
    });
  },
  methods: {
    getFontSize (font_size) {
      if (font_size == 'large') {
        return 36
      } else if (font_size == 'medium') {
        return 32
      }
      return 28
    },
    redirect(event) {
      if (event.currentTarget.dataset.link) {
        app.redirect(event.currentTarget.dataset.link);
      }
    }
  }
})